home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / createdir.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  95 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: createdir.c,v 1.1 1996/09/11 12:54:45 digulla Exp $
  4.     $Log: createdir.c,v $
  5.     Revision 1.1  1996/09/11 12:54:45  digulla
  6.     A couple of new DOS functions from M. Fleischer
  7.  
  8.     Desc:
  9.     Lang: english
  10. */
  11. #include <exec/memory.h>
  12. #include <clib/exec_protos.h>
  13. #include <utility/tagitem.h>
  14. #include <dos/dos.h>
  15. #include <dos/filesystem.h>
  16. #include <clib/dos_protos.h>
  17. #include <clib/utility_protos.h>
  18. #include "dos_intern.h"
  19.  
  20. /*****************************************************************************
  21.  
  22.     NAME */
  23.     #include <clib/dos_protos.h>
  24.  
  25.     __AROS_LH1(BPTR, CreateDir,
  26.  
  27. /*  SYNOPSIS */
  28.     __AROS_LHA(STRPTR, name, D1),
  29.  
  30. /*  LOCATION */
  31.     struct DosLibrary *, DOSBase, 20, Dos)
  32.  
  33. /*  FUNCTION
  34.     Creates a new directory under the given name. If all went an
  35.     exclusive lock on the new diretory is returned.
  36.  
  37.     INPUTS
  38.     name       - NUL terminated name.
  39.  
  40.     RESULT
  41.     Exclusive lock to the new directory or 0 if couldn't be created.
  42.     IoErr() gives additional information in that case.
  43.  
  44.     NOTES
  45.  
  46.     EXAMPLE
  47.  
  48.     BUGS
  49.  
  50.     SEE ALSO
  51.  
  52.     INTERNALS
  53.  
  54.     HISTORY
  55.     29-10-95    digulla automatically created from
  56.                 dos_lib.fd and clib/dos_protos.h
  57.  
  58. *****************************************************************************/
  59. {
  60.     __AROS_FUNC_INIT
  61.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  62.  
  63.     struct FileHandle *ret;
  64.  
  65.     /* Get pointer to process structure */
  66.     struct Process *me=(struct Process *)FindTask(NULL);
  67.  
  68.     /* Get pointer to I/O request. Use stackspace for now. */
  69.     struct IOFileSys io,*iofs=&io;
  70.  
  71.     /* Allocate memory for lock */
  72.     ret=(struct FileHandle *)AllocDosObject(DOS_FILEHANDLE,NULL);
  73.     if(ret!=NULL)
  74.     {
  75.         /* Prepare I/O request. */
  76.         iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  77.         iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  78.         iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  79.         iofs->IOFS.io_Flags=0;
  80.         iofs->IOFS.io_Command=FSA_CREATE_DIR;
  81.         /* io_Args[0] is the name which is set by DoName(). */
  82.         iofs->io_Args[1]=FIBF_READ|FIBF_WRITE|FIBF_EXECUTE|FIBF_DELETE;
  83.         if(!DoName(iofs,name))
  84.         {
  85.             ret->fh_Unit  =iofs->IOFS.io_Unit;
  86.             ret->fh_Device=iofs->IOFS.io_Device;
  87.             return MKBADDR(ret);
  88.         }
  89.         FreeDosObject(DOS_FILEHANDLE,ret);
  90.     }else
  91.     me->pr_Result2=ERROR_NO_FREE_STORE;
  92.     return 0;
  93.     __AROS_FUNC_EXIT
  94. } /* CreateDir */
  95.